const _ = require('lodash')


module.exports = ({useragents}) => {
    const fakeUseragents = require('./fake_useragents')

    return (request) => {
        if (!_.isUndefined(request.useragent)) {
            return request.useragent
        }
        if (!_.isEmpty(useragents)) {
            return _.sample(useragents)
        }

        return _.sample(fakeUseragents['chrome']);
    }
}